package com.yuetong.quotation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yuetong.common.annotation.Log;
import com.yuetong.common.core.controller.BaseController;
import com.yuetong.common.core.domain.AjaxResult;
import com.yuetong.common.enums.BusinessType;
import com.yuetong.quotation.domain.YtQuotationSummary;
import com.yuetong.quotation.service.IYtQuotationSummaryService;
import com.yuetong.common.utils.poi.ExcelUtil;
import com.yuetong.common.core.page.TableDataInfo;

/**
 * 报价汇总Controller
 * 
 * @author  卓晓君
 * @date 2025-02-11
 */
@RestController
@RequestMapping("/quotation/summary")
public class YtQuotationSummaryController extends BaseController
{
    @Autowired
    private IYtQuotationSummaryService ytQuotationSummaryService;

    /**
     * 查询报价汇总列表
     */
    @PreAuthorize("@ss.hasPermi('quotation:summary:list')")
    @GetMapping("/list")
    public TableDataInfo list(YtQuotationSummary ytQuotationSummary)
    {
        startPage();
        List<YtQuotationSummary> list = ytQuotationSummaryService.selectYtQuotationSummaryList(ytQuotationSummary);
        return getDataTable(list);
    }

    /**
     * 导出报价汇总列表
     */
    @PreAuthorize("@ss.hasPermi('quotation:summary:export')")
    @Log(title = "报价汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YtQuotationSummary ytQuotationSummary)
    {
        List<YtQuotationSummary> list = ytQuotationSummaryService.selectYtQuotationSummaryList(ytQuotationSummary);
        ExcelUtil<YtQuotationSummary> util = new ExcelUtil<YtQuotationSummary>(YtQuotationSummary.class);
        util.exportExcel(response, list, "报价汇总数据");
    }

    /**
     * 获取报价汇总详细信息
     */
    @PreAuthorize("@ss.hasPermi('quotation:summary:query')")
    @GetMapping(value = "/{summaryId}")
    public AjaxResult getInfo(@PathVariable("summaryId") Long summaryId)
    {
        return success(ytQuotationSummaryService.selectYtQuotationSummaryBySummaryId(summaryId));
    }

    /**
     * 新增报价汇总
     */
    @PreAuthorize("@ss.hasPermi('quotation:summary:add')")
    @Log(title = "报价汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YtQuotationSummary ytQuotationSummary)
    {
        return toAjax(ytQuotationSummaryService.insertYtQuotationSummary(ytQuotationSummary));
    }

    /**
     * 修改报价汇总
     */
    @PreAuthorize("@ss.hasPermi('quotation:summary:edit')")
    @Log(title = "报价汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YtQuotationSummary ytQuotationSummary)
    {
        return toAjax(ytQuotationSummaryService.updateYtQuotationSummary(ytQuotationSummary));
    }

    /**
     * 删除报价汇总
     */
    @PreAuthorize("@ss.hasPermi('quotation:summary:remove')")
    @Log(title = "报价汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{summaryIds}")
    public AjaxResult remove(@PathVariable Long[] summaryIds)
    {
        return toAjax(ytQuotationSummaryService.deleteYtQuotationSummaryBySummaryIds(summaryIds));
    }
}
